home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / nftp102.zip / STATS.CMD < prev    next >
OS/2 REXX Batch file  |  1997-04-16  |  3KB  |  108 lines

  1. /*
  2.    REXX program to extract statistics from NFTP.FLS file     Version 0.1
  3.    Freely distributable, but copyright by T≤th Ferenc <etus@alarmix.net>
  4.    Please mail any suggestinos and/or bug report to the author.
  5.    
  6.    To do:
  7.    - option to count uploads/downloads separately
  8.    - option to sort sites according to speed or down/upload size
  9.    - option to list only specified time interval
  10. */
  11.  
  12. inputfile = "nftp.fls"
  13. outputfile = "nftp.sta"
  14.  
  15. noecho = LINEOUT(outputfile, "Date      Megabyte     Avarage speed (cps)")
  16. noecho = LINEOUT(outputfile, "------------------------------------------")
  17.  
  18. /* Calculate the number of files and store their date/time, size etc. */
  19. files=1
  20. DO WHILE LINES(inputfile) > 0
  21.   line = LINEIN(inputfile)
  22.   month.files = SUBSTR(line, 4, 2)
  23.   year.files = SUBSTR(line, 7, 2)
  24.   time.files = SUBSTR(line, 10, 5)
  25.   size.files = SUBSTR(line, 16, 9)
  26.   if pos("(", line) = 0 then
  27.   do
  28.   /* old style log without speed */
  29.     speed.files = 0
  30.     site.files = SUBSTR(line, 27, POS(":", line, 27)-27)
  31.   end
  32.   else
  33.   do
  34.   /* new style with speed */
  35.     speed.files = SUBSTR(line, 26, 7)
  36.     site.files = SUBSTR(line, 40, POS(":", line, 40)-40)
  37.   end
  38.   files=files+1
  39. END
  40. files=files-1
  41. month=month.1
  42. year=year.1
  43. bytes=0
  44. time=0
  45.  
  46. /* summary */
  47. do counter=1 to files
  48.   if (month.counter = month) & (year.counter = year) then do
  49.     bytes=bytes+size.counter
  50.     if speed.counter=0 then speed.counter=1
  51.     time=time+size.counter/speed.counter
  52.   end
  53.   else
  54.   do
  55.     if time=0 then time=1
  56.     speed=FORMAT(bytes/time,16,0)
  57.     if speed > 999 then speed=RIGHT(REVERSE(INSERT(",", REVERSE(STRIP(speed)), 3)),16)
  58.     byte=FORMAT(bytes/1024/1024,8,2)
  59.     donotecho = LINEOUT(outputfile, month"/"year||byte||speed)
  60.  
  61.     month=month.counter
  62.     year=year.counter
  63.     bytes=size.counter
  64.     if speed.counter=0 then speed.counter=1
  65.     time=size.counter/speed.counter
  66.   end
  67. END
  68.  
  69. if time=0 then time=1
  70. speed=FORMAT(bytes/time,16,0)
  71. if speed > 999 then speed=RIGHT(REVERSE(INSERT(",", REVERSE(STRIP(speed)), 3)),16)
  72. byte=FORMAT(bytes/1024/1024,8,2)
  73. donotecho = LINEOUT(outputfile, month"/"year||byte||speed)
  74.  
  75. noecho = LINEOUT(outputfile, "")
  76. noecho = LINEOUT(outputfile, "Site                                      Megabyte     Avarage speed (cps)")
  77. noecho = LINEOUT(outputfile, "--------------------------------------------------------------------------")
  78. noecho = LINEOUT(outputfile, "")
  79.  
  80. do numsites=1 to files
  81.   bytes=0
  82.   time=0
  83.  
  84.   already=0
  85.   if numsites>1 then
  86.   do check=1 to numsites-1
  87.     if site.numsites=site.check then already=1
  88.   end
  89.   if already = 0 then
  90.   do
  91.     do counter=1 to files
  92.       if (site.counter = site.numsites) then
  93.       do
  94.         bytes=bytes+size.counter
  95.         if speed.counter=0 then speed.counter=1
  96.         time=time+size.counter/speed.counter
  97.       end
  98.     end
  99.     speed=FORMAT(bytes/time,16,0)
  100.     if speed > 999 then speed=RIGHT(REVERSE(INSERT(",", REVERSE(STRIP(speed)), 3)),16)
  101.     byte=FORMAT(bytes/1024/1024,8,2)
  102.     if speed=1 then speed=""
  103.     donotecho = LINEOUT(outputfile, overlay(" ", site.numsites,38,0)||byte||"    "||speed)
  104.   end
  105. end
  106.  
  107. EXIT
  108.